<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateQuestionAnswer extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('issue_category', ['comment' => '问题类目表(区分当前下属问题属于哪个类目)']);
        $table->addColumn('issue_title', 'string',array('limit' => 355,'null' => true, 'comment' => '问题名称'))
            ->addColumn('issue_status', 'boolean',array('limit' => 1, 'default' => 0, 'comment' => '是否开启'))
            ->addColumn('issue_remark', 'string',array('limit' => 30, 'null' => true, 'comment' => '问题类目备注'))
            ->addColumn('questionnaire_id', 'integer',array('limit' => 30, 'default' => 0,'comment' => '问卷id'))
            ->addTimestamps()
            ->addSoftDelete()
            ->addIndex(array('issue_title'))
            ->create();


        $table = $this->table('issue_question', ['comment' => '问题表']);
        $table->addColumn('issue_question_title', 'string',array('limit' => 355,'null' => true, 'comment' => '问题名称'))
            ->addColumn('issue_question_status', 'boolean',array('limit' => 1, 'default' => 0, 'comment' => '是否开启'))
            ->addColumn('issue_question_remark', 'string',array('limit' => 30, 'null' => true, 'comment' => '问题备注'))
            ->addColumn('issue_question_type', 'boolean',array('limit' => 1, 'default' => 0, 'comment' => '题目类型[1单选,2多选,3阅读理解,4评分题->打分题]'))
            ->addColumn('issue_category_id', 'integer',array('limit' => 30, 'default' => 0,'comment' => '问题类目表id'))
            ->addColumn('questionnaire_id', 'integer',array('limit' => 30, 'default' => 0,'comment' => '问卷id'))
            ->addTimestamps()
            ->addSoftDelete()
            ->addIndex(array('issue_question_title'))
            ->create();


        $table = $this->table('issue_question_answer', ['comment' => '问题答案表']);
        $table->addColumn('issue_answer_title', 'string',array('limit' => 355, 'null' => true,'comment' => '答案名称'))
            ->addColumn('issue_answer_status', 'boolean',array('limit' => 1, 'default' => 0, 'comment' => '是否开启'))
            ->addColumn('issue_answer_remark', 'string',array('limit' => 30, 'null' => true, 'comment' => '问题答案备注'))
            ->addColumn('issue_answer_type', 'boolean',array('limit' => 1, 'default' => 0, 'comment' => '答案是否终止类型[1继续,2终止]'))
            ->addColumn('is_write', 'boolean',array('limit' => 1, 'default' => 0, 'comment' => '选择的答案是否需要自定义填写[0不需要,1需要]'))
            ->addColumn('issue_question_id', 'integer',array('limit' => 30,'default' => 0, 'comment' => '问题表id'))
            ->addColumn('issue_category_id', 'integer',array('limit' => 30,'default' => 0, 'comment' => '问题类目表id'))
            ->addColumn('questionnaire_id', 'integer',array('limit' => 30,'default' => 0, 'comment' => '问卷id'))
            ->addTimestamps()
            ->addSoftDelete()
            ->addIndex(array('issue_answer_title'))
            ->create();
    }
}
